﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using TravelAgencyDAL;

namespace ClientSide
{
    public partial class frmLogin1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            lbSignUp.Click += new EventHandler(lbSignUp_Click);
            crUserWizard.CreatedUser += new EventHandler(crUserWizard_CreatedUser);
        }

        void crUserWizard_CreatedUser(object sender, EventArgs e)
        {
            TextBox tb_FirstName = (crUserWizard.WizardSteps[0].Controls[0].FindControl("FirstName")) as TextBox;
            TextBox tb_LastName = (crUserWizard.WizardSteps[0].Controls[0].FindControl("LastName")) as TextBox;
            string firstName = tb_FirstName.Text;
            string lastName = tb_LastName.Text;
            string eMail = crUserWizard.UserName;

            DAO.AddUser(firstName, lastName, eMail);

            crUserWizard.MoveTo(crUserWizard.CompleteStep);
        }


        void lbSignUp_Click(object sender, EventArgs e)
        {
            crUserWizard.Visible = !(crUserWizard.Visible);
        }

        protected void Login_OnLoging(object sender, EventArgs e)
        {
            if (Session["type"] != null)
            {
                if (Session["type"].ToString() == "book")
                {
                    Response.Redirect("frmBook.aspx");
                }
                else
                {
                    Response.Redirect("frmComplexBook.aspx");
                }
                
            }
            else
            {
                Response.Redirect("frmHome.aspx");
            }
        }
    }
}
